package io.gitee.dqcer.mcdull.uac.provider;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.gitee.dqcer.mcdull.uac.provider.common.utils.poi.ExcelUtil;
import io.gitee.dqcer.mcdull.uac.provider.system.domain.CarVehicle;
import io.gitee.dqcer.mcdull.uac.provider.system.domain.vo.CarVehicleVO;
import io.gitee.dqcer.mcdull.uac.provider.system.service.ICarVehicleService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.gitee.dqcer.mcdull.uac.provider.common.annotation.Log;
import io.gitee.dqcer.mcdull.uac.provider.common.core.controller.BaseController;
import io.gitee.dqcer.mcdull.uac.provider.common.core.domain.AjaxResult;
import io.gitee.dqcer.mcdull.uac.provider.common.enums.BusinessType;
import io.gitee.dqcer.mcdull.uac.provider.common.core.page.TableDataInfo;

/**
 * vehicleInfoController
 * 
 * @author ruoyi
 * @date 2023-12-10
 */
@RestController
@RequestMapping("/system/vehicle")
public class CarVehicleController extends BaseController
{
    @Autowired
    private ICarVehicleService carVehicleService;

    /**
     * 查询vehicleInfo列表
     */
    @PreAuthorize("@ss.hasPermi('system:vehicle:list')")
    @GetMapping("/list")
    public TableDataInfo list(CarVehicle carVehicle)
    {
        startPage();
        List<CarVehicleVO> list = carVehicleService.selectCarVehicleList(carVehicle);
        return getDataTable(list);
    }

    /**
     * 导出vehicleInfo列表
     */
    @PreAuthorize("@ss.hasPermi('system:vehicle:export')")
    @Log(title = "vehicleInfo", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CarVehicle carVehicle)
    {
        List<CarVehicleVO> list = carVehicleService.selectCarVehicleList(carVehicle);
        ExcelUtil<CarVehicleVO> util = new ExcelUtil<CarVehicleVO>(CarVehicleVO.class);
        util.exportExcel(response, list, "vehicleInfo数据");
    }

    /**
     * 获取vehicleInfo详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:vehicle:query')")
    @GetMapping(value = "/{vehicleId}")
    public AjaxResult getInfo(@PathVariable("vehicleId") Long vehicleId)
    {
        return success(carVehicleService.selectCarVehicleByVehicleId(vehicleId));
    }

    /**
     * 新增vehicleInfo
     */
    @PreAuthorize("@ss.hasPermi('system:vehicle:add')")
    @Log(title = "vehicleInfo", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CarVehicle carVehicle)
    {
        return toAjax(carVehicleService.insertCarVehicle(carVehicle));
    }

    /**
     * 修改vehicleInfo
     */
    @PreAuthorize("@ss.hasPermi('system:vehicle:edit')")
    @Log(title = "vehicleInfo", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CarVehicle carVehicle)
    {
        return toAjax(carVehicleService.updateCarVehicle(carVehicle));
    }

    /**
     * 删除vehicleInfo
     */
    @PreAuthorize("@ss.hasPermi('system:vehicle:remove')")
    @Log(title = "vehicleInfo", businessType = BusinessType.DELETE)
	@DeleteMapping("/{vehicleIds}")
    public AjaxResult remove(@PathVariable Long[] vehicleIds)
    {
        return toAjax(carVehicleService.deleteCarVehicleByVehicleIds(vehicleIds));
    }
}
